﻿<?
function generate_cate($iCat){
    switch($iCat){
        case 1:
            return '/xa-hoi.htm';
        break;
        case 2:
            return '/the-gioi.htm';
        break;
        case 3:
            return '/kinh-te.htm';
        break;
        case 4:
            return '/phap-luat.htm';
        break;
        case 5:
            return '/bong-da.htm';
        break;
        case 6:
            return '/cong-nghe.htm';
        break;
        case 7:
            return '/van-hoa.htm';
        break;
        case 14:
            return '/giai-tri.htm';
        break;
        case 8:
            return '/khoa-hoc.htm';
        break;
        case 12:
            return '/tinh-yeu-gioi-tinh.htm';
        break;
        case 9:
            return '/gioi-tre.htm';
        break;
        case 10:
            return '/giao-duc.htm';
        break;
        case 11:
            return '/o-to-xe-may.htm';
        break;
        case 13:
            return '/chuyen-la.htm';
        break;
    }
}
function generate_detail_url($myNews,$nCat=NULL){
    return '/'.removeTitle($nCat).'/'.removeTitle($myNews['new_title']).'-'.$myNews['new_id'].'.html';
}
function generate_cat_page_url($title,$page){
    return '/'.removeTitle($title).'/trang-'.$page.'.htm';
}
function generate_cat_url($title,$id){
    return '/'.removeTitle($title).'-'.$id.'.htm';
}
function generate_cat_mobile_url($cat){
    return '/m/'.removeTitle($cat['cat_name']).'-'.$cat['cat_id'].'.mch';
}
function generate_quotes_url($quote){
    return '/quotes/'.$quote['quo_id'].'/'.removeTitle($quote['quo_name']);
}
function generate_events_url($event){
    return '/events/'.$event['eve_id'].'/'.removeTitle($event['eve_title']);
}
function generate_tags_url($tags) {
    return '/tags/'.$tags.'';
}
function removeTitle($string,$keyReplace = "/"){
	 $string	= removeSign($string);
	 $string	=  trim(preg_replace("/[^A-Za-z0-9]/i"," ",$string)); // khong dau
	 $string  	=  str_replace(" ","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace("--","-",$string);
	 $string 	= str_replace($keyReplace,"-",$string);
	 return strtolower($string);
}
?>